package testrj.sample.web;

import java.lang.reflect.Field;

import testrj.rjson.transformer.FieldBasedTransformer;

public class HttpSessionTransformer extends FieldBasedTransformer {
	@Override
	public boolean canHandle(Object object) {
		if(object instanceof javax.servlet.http.HttpSession) {
			return true;
		}
		return false;
	}
	
	@Override
	public boolean include(Field field) {
		if(field.getName().trim().equals("session") || field.getName().trim().equals("attributes")) {
			return true;
		}
		return false;
	}
	
//	@Override
//	public void transform(Object object, Printer printer, Rjson rjson) {
//		if(object != null) {
//			HttpSession session = (HttpSession) object;
//			printFieldName("org.springframework.mock.web.MockHttpSession", printer);
//			Map<String, Object> attributes = new HashMap<String, Object>();
//			Enumeration e = session.getAttributeNames();
//			while(e.hasMoreElements()) {
//				String key = e.nextElement().toString();
//				attributes.put(key, session.getAttribute(key));
//			}
//			delegateHandlingOf(attributes, printer, rjson);
//		}
//	}
}